# Copyright (c) 2025 Huawei Technologies Co., Ltd.
# This file is a part of the CANN Open Software.
# Licensed under CANN Open Software License Agreement Version 1.0 (the "License").
# Please refer to the License for details. You may not use this file except in compliance with the License.
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
# INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
# See LICENSE in the root of the software repository for the full text of the License.
# ======================================================================================================================

if(EXISTS ${ASCEND_CANN_PACKAGE_PATH}/compiler/tikcpp/ascendc_kernel_cmake)
    set(ASCENDC_CMAKE_DIR ${ASCEND_CANN_PACKAGE_PATH}/compiler/tikcpp/ascendc_kernel_cmake)
elseif(EXISTS ${ASCEND_CANN_PACKAGE_PATH}/tools/tikcpp/ascendc_kernel_cmake)
    set(ASCENDC_CMAKE_DIR ${ASCEND_CANN_PACKAGE_PATH}/tools/tikcpp/ascendc_kernel_cmake)
else()
    message(FATAL_ERROR "ascendc_kernel_cmake does not exist ,please check whether the cann package is installed")
endif()
include(${ASCENDC_CMAKE_DIR}/ascendc.cmake)

ascendc_library(ascendc_kernels_${RUN_MODE} STATIC
    ${KERNEL_FILES}
)

ascendc_compile_definitions(ascendc_kernels_${RUN_MODE} PRIVATE
    ASCENDC_DUMP
    HAVE_WORKSPACE
    HAVE_TILING
)

message(STATUS "[INFO] NPU/SIM Target PERF_MODE is ${PERF_MODE}")
if (PERF_MODE GREATER 0)
    ascendc_compile_definitions(ascendc_kernels_${RUN_MODE} PRIVATE
        ENABLE_CUBE_ONLY
    )
    message(STATUS "[INFO] NPU/SIM Target Enable CUBE_ONLY")
endif()
if (PERF_MODE GREATER 1)
    ascendc_compile_definitions(ascendc_kernels_${RUN_MODE} PRIVATE
        ENABLE_MDL
    )
    message(STATUS "[INFO] NPU/SIM Target Enable MDL")
endif()
if (PERF_MODE GREATER 2)
    ascendc_compile_definitions(ascendc_kernels_${RUN_MODE} PRIVATE
        ENABLE_MDL_UNITFLAG
    )
    message(STATUS "[INFO] NPU/SIM Target Enable MDL UNITFLAG")
endif()
